export default class Priority extends zrender.Group{
    constructor(priority,node){
        super();
        this.config={                  //颜色配置
            1:{fill:'#F54545',stroke:'#FF0000' },
            2:{fill:'#F57F31',stroke:'#FF9933' },
            3:{fill:'#F5E614',stroke:'#F8FF33' },
            4:{fill:'#D6B656',stroke:'#D6B656' },
            5:{fill:'#8DFF54',stroke:'#78D63A' },
            6:{fill:'#10DB83',stroke:'#0CA864' },
            7:{fill:'#4280FC',stroke:'#6C8EBF' },
            8:{fill:'#B0B0B0',stroke:'#666666' },
            9:{fill:'#CFCFCF',stroke:'#A3A3A3' }
        };
        //这里需要对参数priority做限定，以增强程序的稳定性，这里就省略了
        this.data={...this.config[priority],...{text:priority,textFill:'#fff',fontSize:10}};
        this.node=node||null;
        this.render();
    }
    render(){
        this.circle=new zrender.Circle({
            style:this.data,
            shape:{
                cx:8,
                cy:8,
                r:8
            },
            z:12
        });
        this.add(this.circle);
    }
    setText(priority){
        this.data={...this.data,...this.config[priority],...{text:priority}};
        this.circle.attr({
            style:this.data
        });
    }
    getText(){
        return this.circle.style.text;
    }
    setPosition(x,y){
      this.attr({position:[x,y]})
    }
    getPosition(){
      var p=this.position.slice();
      return {
        x:p[0],
        y:p[1]
      }
    }
}
